
//
// Copyright 2009 Arne Halvorsen (arne.halvorsen@gmail.com)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

// Project page: http://code.google.com/p/mf4j/

//
// 091116 - aha42 - Starts in line change tracking.
// 091119 - aha42 - Renamed from FlickrObjectVisitor.
// 091121 - aha42 - Added project page link (google code) to header comment.
//

package org.aha.mf4j.visitor;

import org.aha.mf4j.response.FlickrObject;

/**
 * <p>
 *   Base class for objects traversing a
 *   {@link FlickrObject} hierarchy.
 * </p>
 * <p>
 *   Objects of this type are passed as arguments to
 *   {@link FlickrObject#visit(Visitor)} and
 *   {@link FlickrObject#visit(FlickrObject[], Visitor)}.
 * </p>
 * @author Arne Halvorsen (aha42)
 */
public abstract class Visitor 
{
  /**
   * <p>
   *   Invoked before first object visited.
   * </p>
   */
  public void start(){};
  
  /**
   * <p>
   *   Visits.
   * </p>
   * @param level   Depth in hierarchy we are at, root is at level {@code 0}.
   * @param visited Object visited.
   * @return {@code true} if to continue to traverse hierarchy, {@code false} 
   *         if is not.
   */
  public abstract boolean visit(int level, FlickrObject visited);
  
  /**
   * <p>
   *   Invoked when last object has been visited.
   * </p>
   */
  public void end(){}
  
}
